//
//  TVStatementMonthCellModel.swift
//  iPhone
//
//  Created by Toj on 11/16/22.
//

import UIKit

class TVStatementMonthCellModel: NSObject {
    var isSelected = false
    private(set) var month = ""
    private(set) var year = ""
    
    private(set) var startDate: Date?
    private(set) var startDateString: String = ""
    private(set) var startDateTimestamp_s: TimeInterval = 0
    private(set) var startDateTimestamp_ms: TimeInterval = 0
    
    private(set) var lastDate: Date?
    private(set) var lastDateString: String = ""
    private(set) var lastDateTimestamp_s: TimeInterval = 0
    private(set) var lastDateTimestamp_ms: TimeInterval = 0
    
    init(firstDay date: Date, formatter: DateFormatter) {
        super.init()
        
        startDate = date
        startDateString = formatter.string(from: date)
        startDateTimestamp_s = date.to_timestamp_s
        startDateTimestamp_ms = date.to_timestamp_ms
        
        let lstDate = date.dt_lastDay
        lastDate = lstDate
        lastDateString = formatter.string(from: lstDate)
        lastDateTimestamp_s = lstDate.to_timestamp_s
        lastDateTimestamp_ms = lstDate.to_timestamp_ms
        
        let dates = startDateString.cm_split("/")
        year  = dates.first ?? ""
        month = dates.last ?? ""
    }
}
